package homework;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Homework_P1M3_3 {
    public static void main(String[] args) {
        String[] str ="123,456,789,123,456".split(",");
        Map<String,Integer> strMap = new HashMap<>();
        for (int i =0;i<str.length;i++) {
            if (!strMap.containsKey(str[i])) {
                strMap.put(str[i], 1);
            }else{
                strMap.put(str[i], strMap.get(str[i])+1);
            }
        }
       // 打印结果
        Set<String> keys = strMap.keySet();
        for (String key : keys) {
            System.out.printf("%s出现了%d次;\n",key,strMap.get(key));
        }
    }
}
